<?php $baseUrl = $this->baseUrl(); ?>
<div class="tit-page">
    <h2>Cliente : <?php echo $this->rowCliente->st_nome; ?>
        <a href="<?php echo $baseUrl; ?>/corporativo/cliente/formulario/id/<?php echo $this->rowCliente->id_cliente; ?>" class="ui-icon ui-icon-pencil">Editar</a></h2>
</div>

<div class="tarefa">
    <div class="info-tarefa">
        <ul>
            <?php if ($this->rowCliente->st_CNPJ) : ?>
            <li><strong>CNPJ:</strong> <?php echo $this->rowCliente->st_CNPJ; ?></li>
            <?php endif; ?>
            <?php if ($this->rowCliente->st_CPF) : ?>
            <li><strong>CPF:</strong> <?php echo $this->rowCliente->st_CPF; ?></li>
            <?php endif; ?>
            <li><strong>CEP:</strong> <?php echo $this->rowCliente->st_CEP; ?></li>
            <li><strong>UF:</strong> <?php echo $this->rowCliente->st_UF; ?></li>
            <li><strong>Cidade:</strong> <?php echo $this->rowCliente->st_cidade; ?></li>
            <li><strong>Bairro:</strong> <?php echo $this->rowCliente->st_bairro; ?></li>
            <li><strong>Logradouro:</strong> <?php echo $this->rowCliente->st_logradouro; ?></li>
            <li><strong>Número:</strong> <?php echo $this->rowCliente->st_end_numero; ?></li>
            <li><strong>Telefone:</strong> <?php echo $this->rowCliente->st_telefone; ?></li>
        </ul>
    </div>
</div>
<div>
    <div class="accordion">
        <h3><a href="#">Projetos (<?php echo count($this->rowSetProjetos); ?>)</a></h3>
        <div>
            <div class="ev-option-buttons">
                <a class="ev-dialog-form ui-state-default ui-corner-all" href="<?php echo $baseUrl; ?>/projeto/projeto/novo/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>" title="Novo Projeto">
                    <span class="ui-icon ui-icon-folder-open"></span>
                    Novo projeto
                </a>
            </div>

            <table>
                <thead>
                    <tr>
                        <td>Nome</td>
                        <td>Tipo</td>
                        <td>Situação</td>
                        <td>Responsável</td>
                        <td>Valor</td>
                        <td>Ação</td>
                    </tr>
                </thead>
                <tbody>
        <?php foreach ($this->rowSetProjetos as $rowProjeto) : ?>
                    <tr>
                        <td><a href="<?php echo $baseUrl; ?>/projeto/projeto/visualizar/id/<?php echo $rowProjeto->id_projeto; ?>"><?php echo $rowProjeto->st_nome; ?></a></td>
                        <td><?php echo $this->projetoTipo[$rowProjeto->fk_tipo_projeto]; ?></td>
                        <td><?php echo $this->projetoSituacao[$rowProjeto->cs_situacao]; ?></td>
                        <td><?php echo $this->aUsuarios[$rowProjeto->fk_usuario_responsavel]; ?></td>
                        <td><?php echo $this->currency($rowProjeto->vl_valor); ?></td>
                        <td>
                            <a class="ev-dialog-form" title="Emitir Nova Fiscal" href="<?php echo $baseUrl; ?>/corporativo/nota-fiscal/emitir/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>/fk_projeto/<?php echo $rowProjeto->id_projeto; ?>">
                                <span class="ui-icon ui-icon-document-b">Emitir nota fiscal</span>
                            </a>
                        </td>
                    </tr>
        <?php endforeach; ?>
               </tbody>
            </table>
        </div>

        <h3><a href="#">Serviços (<?php echo count($this->rowSetServicos); ?>)</a></h3>
        <div>
            <div class="ev-option-buttons">
                <a class="ev-dialog-form ui-state-default ui-corner-all" href="<?php echo $baseUrl; ?>/servico/servico/novo/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>">
                    <span class="ui-icon ui-icon-plusthick"></span>
                    Novo Serviço
                </a>
            </div>
            <table>
                <thead>
                    <tr>
                        <td>Serviço</td>
                        <td>Nome</td>
                        <td>Valor</td>
                        <td>Ação</td>
                    </tr>
                </thead>
                <tbody>
        <?php foreach ($this->rowSetServicos as $rowServico) : ?>
                    <tr>
                        <td><a href="<?php echo $baseUrl; ?>/servico/servico/visualizar/id/<?php echo $rowServico->id_servico; ?>"><?php echo $this->aTipoServico[$rowServico->fk_tipo_servico]; ?></a></td>
                        <td><?php echo $rowServico->st_nome; ?></td>
                        <td><?php echo $this->currency($rowServico->vl_valor); ?></td>
                        <td><a href="<?php echo $baseUrl; ?>/corporativo/nota-fiscal/emitir/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>/fk_servico/<?php echo $rowServico->id_servico; ?>" class="ev-dialog-form">Emitir nota fiscal</a></td>
                    </tr>
        <?php endforeach; ?>
               </tbody>
           </table>
        </div>

        <?php echo $this->action('listar', 'artefato', 'corporativo', array('fk_cliente' => $this->rowCliente->id_cliente)); ?>

        <h3><a href="#">Credenciais (<?php echo count($this->rowSetCredenciais); ?>)</a></h3>
        <div>
            <div class="ev-option-buttons">
                <a class="ev-dialog-form ui-state-default ui-corner-all" href="<?php echo $baseUrl; ?>/corporativo/credencial/adicionar/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>">
                    <span class="ui-icon ui-icon-key"></span>
                    Nova Credencial
                </a>
            </div>
            <table>
                <thead>
                    <tr>
                        <th>Nome</th>
                        <th>Acesso</th>
                        <th>Login</th>
                        <th>Senha</th>
                    </tr>
                </thead>
                <tbody>
    <?php foreach ($this->rowSetCredenciais as $rowCredenciall) : ?>
                    <tr>
                        <td><?php  echo $rowCredenciall->st_nome; ?></td>
                        <td><?php  echo $rowCredenciall->st_acesso; ?></td>
                        <td><?php  echo $rowCredenciall->st_login; ?></td>
                        <td><?php  echo $rowCredenciall->st_senha; ?></td>
                    </tr>
    <?php endforeach; ?>
                </tbody>
            </table>
        </div>

       <h3><a href="#">Notas Fiscais (<?php echo count($this->rowSetNotasFiscais); ?>)</a></h3>
        <div>
            <table>
                <thead>
                    <tr>
                        <th>Emissão</th>
                        <th>Valor</th>
                        <th>Situação</th>
                    </tr>
                </thead>
                <tbody>
    <?php foreach ($this->rowSetNotasFiscais as $rowNotaFiscal) : ?>
                    <tr>
                        <td><?php  echo $this->dateFormat($rowNotaFiscal->dt_emissao); ?></td>
                        <td><?php  echo $rowNotaFiscal->vl_valor; ?></td>
                        <td><?php  echo $rowNotaFiscal->cs_situacao; ?></td>
                    </tr>
    <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <h3><a href="#">Contatos (<?php echo count($this->rowSetContatos); ?>)</a></h3>
        <div>
            <div class="ev-option-buttons">
                <a class="ev-dialog-form ui-state-default ui-corner-all" href="<?php echo $baseUrl; ?>/corporativo/contato/adicionar/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>">
                    <span class="ui-icon ui-icon-contact"></span>
                    Novo contato
                </a>
            </div>
            <table>
                <thead>
                    <tr>
                        <th>Nome</th>
                        <th>Cargo</th>
                        <th>Email</th>
                        <th>Telefone</th>
                        <th>Telefone</th>
                    </tr>
                </thead>
                <tbody>
    <?php foreach ($this->rowSetContatos as $rowContato) : ?>
                    <tr>
                        <td><?php  echo $rowContato->st_nome; ?></td>
                        <td><?php  echo $rowContato->st_cargo; ?></td>
                        <td><?php  echo $rowContato->st_email; ?></td>
                        <td><?php  echo $rowContato->st_telefone; ?></td>
                        <td><?php  echo $rowContato->st_telefone2; ?></td>
                    </tr>
    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
        <h3><a href="#">Usuários (<?php echo count($this->rowSetUsuarios); ?>)</a></h3>
        <div>
            <div class="ev-option-buttons">
                <a class="ev-dialog-form ui-state-default ui-corner-all" href="<?php echo $baseUrl; ?>/corporativo/cliente/relacionar-usuario/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>">
                    <span class="ui-icon ui-icon-transferthick-e-w"></span>
                    Relacionar usuário
                </a>
            </div>
            <table>
                <thead>
                    <tr>
                        <th>Cadastro</th>
                        <th>Login</th>
                        <th>Nome</th>
                        <th>Email</th>
                        <th>Admin</th>
                        <th>Ação</th>
                    </tr>
                </thead>
                <tbody>
    <?php foreach ($this->rowSetUsuarios as $rowUsuario) : ?>
                    <tr>
                        <td><?php echo $this->dateFormat($rowUsuario->dt_cadastro); ?></td>
                        <td><?php  echo $rowUsuario->st_login; ?></td>
                        <td><?php  echo $rowUsuario->st_nome; ?></td>
                        <td><?php  echo $rowUsuario->st_email; ?></td>
                        <td><?php  echo $rowUsuario->bo_admin; ?></td>
                        <td>
                            <a href="<?php echo $baseUrl; ?>/corporativo/cliente/excluir-usuario/fk_usuario/<?php echo $rowUsuario->id_usuario; ?>/fk_cliente/<?php echo $this->rowCliente->id_cliente; ?>" class="ui-icon ui-icon-close">X</a>
                        </td>
                    </tr>
    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>